/* TotalDcmListerPluginSettings.h -- Header file for class TotalDcmListerPluginSettings
*
* TotalDcmLister - A lister plugin for Total Commander for listing DICOM File content.
*
* Copyright (C) 2015 Captain Stark
*
* This software may be modified and distributed under the terms of the MIT license.
* See the COPYRIGHT file at the top-level directory of this distribution for details.
*/

#pragma once

#include "DicomAttributeGroup.h"

#include <string>
#include <vector>
#include <pugixml.hpp>

using namespace std;
using namespace pugi;

/// <summary>
/// Provides settings for the Total DICOM Lister as stored in an XML settings file.
/// </summary>
class TotalDcmListerPluginSettings
{
public:
   /// <summary>
   /// Initializes a new instance of the <see cref="TotalDcmListerPluginSettings"/> class.
   /// </summary>
   /// <param name="settingsLocation">Location of the settings file.</param>
   TotalDcmListerPluginSettings(const wstring& settingsLocation);

   /// <summary>
   /// Finalizes an instance of the <see cref="TotalDcmListerPluginSettings"/> class.
   /// </summary>
   ~TotalDcmListerPluginSettings();

   /// <summary>
   /// Gets a value indicating whether missing attributes shall be displayed or not.
   /// </summary>
   /// <returns>The setting's value.</returns>
   const bool DisplayMissingAttributes();

   /// <summary>
   /// Gets the default value to be displayed for missing attributes.
   /// </summary>
   /// <returns>The setting's value.</returns>
   const wstring DefaultValueForMissingAttributes();

   /// <summary>
   /// Gets a list of the DICOM data to be displayed. 
   /// The list contains groups of DICOM data to be displayed while each group contains attributes to display.
   /// </summary>
   /// <returns>A list of the DICOM data to be displayed.</returns>
   const vector<DicomAttributeGroup> DicomDataToDisplay();

private:
   wstring m_settingsFileName;
   xml_document m_settingsDocument;
   bool m_displayMissingAttributes;
   wstring m_defaultValueForMissingAttributes;
   vector<DicomAttributeGroup> m_dicomDataToDisplay;

   void CreateDefaultSettings();
   bool GetAppSettingAsBool(const wstring& settingName, const bool defaultValue);
   wstring GetAppSettingAsString(const wstring& settingName, const wstring& defaultValue);
   void LoadDicomDataToDisplay();

   void SetAppSettingAsBool(const wstring& name, const bool value);
   void SetAppSettingAsString(const wstring& name, const wstring& value);
   void SetDicomAttributeToDisplay(const wstring& group, const wstring& tag, const wstring& name);
   xml_node FindOrCreateAppSettingWithName(const wstring& name);
};

